/**
 * @author antonio081014
 * @since Jan 19, 2012, 6:25:15 PM
 */

public class GogoXCake {
    public String solve(String[] cake, String[] cutter) {
        for (int i = 0; i + cutter.length <= cake.length; i++) {
            for (int j = 0; j + cutter[0].length() <= cake[i].length(); j++) {
                if (checkCutter(cake, cutter, i, j)) {
                    for (int x = 0; x < cutter.length; x++) {
                        for (int y = 0; y < cutter[x].length(); y++) {
                            if (cutter[x].charAt(y) == '.')
                                cake[i + x] = cake[i + x].substring(0, y + j)
                                        + "X"
                                        + cake[i + x].substring(y + j + 1);
                        }
                    }
                }
            }
        }
        return checkCake(cake) ? "YES" : "NO";
    }

    public void print(String[] cake) {
        for (int i = 0; i < cake.length; i++)
            System.out.println(cake[i]);
    }

    public boolean checkCake(String[] cake) {
        for (int i = 0; i < cake.length; i++)
            for (int j = 0; j < cake[i].length(); j++)
                if (cake[i].charAt(j) == '.')
                    return false;
        return true;
    }

    public boolean checkCutter(String[] cake, String[] cutter, int x, int y) {
        for (int i = 0; i < cutter.length; i++) {
            for (int j = 0; j < cutter[i].length(); j++) {
                if (cutter[i].charAt(j) == '.')
                    if (cake[i + x].charAt(j + y) != cutter[i].charAt(j)) {
                        return false;
                    }
            }
        }
        return true;
    }

    // <%:testing-code%>
}
// Powered by [KawigiEdit] 2.0!
